import 'package:flutter/material.dart';

import '../../../common/my_icon.dart';
import '../../../config/global_config.dart';
import '../../../model/bean/notice_bean.dart';
import '../../../utils/screenutil/fit.dart';

class NoticeList extends StatelessWidget {
  static Map<int, dynamic> noticeType = {
    1: {
      "icon": MyIcon.sz,
      "msg": "系统消息",
      "color": Color.fromRGBO(253, 157, 0, 1),
    },
    2: {
      "icon": MyIcon.wbjl,
      "msg": "维保消息",
      "color": Color.fromRGBO(49, 158, 232, 1),
    },
    3: {
      "icon": MyIcon.gg,
      "msg": "告警消息",
      "color": Color.fromRGBO(253, 38, 0, 1),
    },
    4: {
      "icon": MyIcon.wxcl,
      "msg": "报修提醒",
      "color": Color.fromRGBO(253, 157, 0, 1)
    }
  };

  NoticeBean notice;

  NoticeList(NoticeBean notice) : this.notice = notice;

  @override
  Widget build(BuildContext context) {
    // print(this.notice);
    // print(this.notice.type);
    // print(noticeType[this.notice.type]);
    return Container(
      width: fit(640),
      padding: EdgeInsets.only(left: 20.f, top: 20.f),
      color: Colors.white,
      child: Column(
        children: [
          Container(
            margin: EdgeInsets.only(bottom: 20.f),
            child: Row(
              children: [
                Container(
                  width: 60.f,
                  height: 60.f,
                  margin: EdgeInsets.only(right: 20.f),
                  decoration: BoxDecoration(
                    color: noticeType[notice.type]["color"],
                    borderRadius: BorderRadius.circular(30.f),
                  ),
                  child: Icon(
                    // MyIcon.sz,
                    noticeType[notice.type]["icon"],
                    size: 30.f,
                    color: Colors.white,
                  ),
                ),
                Container(
                  width: 520.f,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        margin: EdgeInsets.only(bottom: 10.f),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text(
                              "${noticeType[notice.type]["msg"]}",
                              style: TextStyle(
                                fontSize: 24.f,
                                color: GlobalConfig.titleColor,
                              ),
                            ),
                            Text(
                              "${notice.createTime}",
                              style: TextStyle(
                                fontSize: 22.f,
                                color: GlobalConfig.assistColor,
                              ),
                            ),
                          ],
                        ),
                      ),
                      Text(
                        "${notice.content}",
                        style: TextStyle(
                          fontSize: 22.f,
                          color: GlobalConfig.titleContent,
                        ),
                      )
                    ],
                  ),
                )
              ],
            ),
          ),
          SizedBox(
            width: 620.f,
            height: 1.f,
            child: Container(color: GlobalConfig.borderColor),
          ),
        ],
      ),
    );
  }
}
